/*
 *  Copyright 2019-2025 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.transfer.rest;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.modules.system.service.MenuService;
import me.zhengjie.modules.transfer.domain.TransferAa10;
import me.zhengjie.modules.transfer.domain.TransferAc10;
import me.zhengjie.modules.transfer.service.TransferAa10Service;
import me.zhengjie.tool.ListUtil;
import me.zhengjie.tool.SelectTreeUtil;
import me.zhengjie.tool.SelectTreeVo;
import me.zhengjie.tool.ValidateUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 行政区划代码
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "系统：行政区划代码")
@RequestMapping("/api/aa10")
public class TransferAa10Controller {

    private final TransferAa10Service transferAa10Service;

    @PostMapping("getaa10")
    public ResponseEntity<Object> queryAllMenu(@RequestBody Map pid){
        QueryWrapper<TransferAa10> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("aaa100","AAB301");
        List<TransferAa10> list = transferAa10Service.list(queryWrapper);
        List<SelectTreeVo> selectTreeVos = list.stream().map(taDictPo -> {
            SelectTreeVo selectTreeVo = new SelectTreeVo();
            selectTreeVo.setId(taDictPo.getAaa102().toString());
            selectTreeVo.setName(taDictPo.getAaa103());
            selectTreeVo.setpId(ValidateUtil.isEmpty(taDictPo.getAaa483()) ? "0" : taDictPo.getAaa483());
            return selectTreeVo;
        }).collect(Collectors.toList());
        SelectTreeUtil selectTreeUtil = new SelectTreeUtil();
        List<Map<String, Object>> maps = selectTreeUtil.menuList(selectTreeVos, "", false);
        return new ResponseEntity<>(maps,HttpStatus.OK);
    }



}
